﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DataAccess;

namespace QLDSVCNTT_Nhom1
{
    public partial class frmQLMonHoc : Form
    {
        public frmQLMonHoc()
        {
            InitializeComponent();
        }

        private void frmQLMonHoc_Load(object sender, EventArgs e)
        {
            List<string> hk = new List<string> { "1", "2", "3" };
            cbbHocKy.DataSource = hk;
            cbbNamHoc.Items.Insert(0,"-- Chon nam --");
            cbbNamHoc.SelectedIndex = 0;
            //cbbHocKy.SelectedIndex = 0;
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void cbbNamHoc_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbbNamHoc.SelectedIndex > 0)
            {
                string nam = cbbNamHoc.SelectedItem as string;
                List<MonHoc> list = MonHoc.XemMonHocTheoNamHoc(nam);
                BindLVMonHoc(list);
                List<string> maMH = new List<string>();
                foreach (MonHoc mh in list)
                    maMH.Add(mh.MaMH);
                cbbMaMH.DataSource = maMH;
                cbbMaMH.SelectedIndex = 0;
            }
        }
        private void BindLVMonHoc(List<MonHoc> list)
        {
            lvMonHoc.Items.Clear();
            foreach (MonHoc mh in list)
            {
                ListViewItem lvi = lvMonHoc.Items.Add(mh.MaMH.ToString());
                lvi.SubItems.Add(mh.TenMH.ToString());
                //lvi.SubItems.Add("Hoc ky");
                //lvi.SubItems.Add("Nam hoc");
                lvi.SubItems.Add(mh.SoTC.ToString());
                lvi.SubItems.Add(mh.TCLT.ToString());
                lvi.SubItems.Add(mh.TCTH.ToString());
                lvi.SubItems.Add(mh.BatBuoc.ToString());
                lvi.SubItems.Add(mh.MoTaMH.ToString());

            }
        }
    }
}
